import haversine from 'haversine-distance'

// 获取当前经纬度
export function getFuzzyLocation() {
    return new Promise((resolve, reject) => {
        wx.getFuzzyLocation({
            type: 'gcj02',
            success: resolve,
            fail: reject,
        })
    })
}

// 距离排序
export function distanceSort(list = [], location) {
    list.forEach(item => item._distance = haversine(location, item))
    list.sort((a, b) => a._distance - b._distance)
}
